﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace Winter.BackEnd
{
    // Note: For instructions on enabling IIS6 or IIS7 classic mode, 
    // visit http://go.microsoft.com/?LinkId=9394801

    public class MvcApplication : System.Web.HttpApplication
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                null,
                "",
                new { controller = "Home", action = "Index" }
            );
            routes.MapRoute(
                null,
                "Person/{id}",
                new { controller = "Person", action = "Index" },
                new { id = @"\d+" }
            );
            routes.MapRoute(
                null,
                "Person/Info/{id}",
                new { controller = "Person", action = "GetPersonInfo" },
                new { id = @"\d+" }
            );
            routes.MapRoute(
               null,
               "Class/Details/{id}",
               new { controller = "Classes", action = "Details" },
               new { id = @"\d+" }
           );
            routes.MapRoute(
              null,
              "Classes/Map/{buildingName}",
              new { controller = "Classes", action = "Map" },
              new { buildingName = @".+" }
          );

            routes.MapRoute(
               "Jquery",
               "Group/GetShortSubjectDetails/{Id}",
               new { controller = "Group", action = "GetShortSubjectDetails" });

            routes.MapRoute(
               "JqueryGroup",
               "Group/GetScheduleForGroup/{Id}",
               new { controller = "Group", action = "GetScheduleForGroup" });

            routes.MapRoute(
              "JqueryGroupSave",
              "Group/SaveClass/{id}/{subjectID}/{teacherID}/{buildingID}/{room}/{groupID}",
              new { controller = "Group", action = "SaveClass" });

            routes.MapRoute(
              "JqueryUniversities",
              "Universities/GetItemDetails/{CategoryName}/{Id}",
              new { controller = "Universities", action = "GetItemDetails" });

            routes.MapRoute(
             "JqueryUniversitiesStudents",
             "Universities/GetStudetnsForItem/{CategoryName}/{Id}",
             new { controller = "Universities", action = "GetStudetnsForItem" });

            routes.MapRoute(
                null,
                "{controller}/{action}",
                new { controller = "", action = "Index" }
            );
        }

        protected void Application_Start()
        {
            RegisterRoutes(RouteTable.Routes);
            //ControllerBuilder.Current.SetControllerFactory(new WindsorControllerFactory());
        }
    }
}